home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 2 / LSD and 17bit Compendium Deluxe - Volume II.iso / a / prog / asmsrc / tango2.lha / SOURCES / SIN.TEST < prev    next >
Encoding:
Text File  |  1988-07-19  |  11.5 KB  |  572 lines

  1. ;    ** RAY SEE IF KODAK CAN MAKE THIS ANY BETTER **
  2. ; ** 2 PIXEL ACCURACY SINE WAVE BY TANGO OF CRYPTIC **
  3. ;     ** ONLY SPREAD SOURCE TO CRYPTIC MEMBERS **
  4.  
  5.     opt c-
  6.     section blitter,code_c            Chip Ram please !!
  7.     include    df1:definitions            Give me some hardware reggies
  8.     include    df1:macros                Give me some macros
  9.     
  10.         
  11. ;LOCAL CONSTANTS
  12.  
  13. icra        equ $bfed01                
  14. allocmem     =-30-168                
  15. freemem     =-30-180                
  16.  
  17. TAKEOVER:
  18.  
  19. ; KILL SYSTEM COPPER, KEYBOARD ETC.....
  20.  
  21.     LEA custom,a5        
  22.     LEA GFXLIB(PC),a1             Point to 'graphics.library'
  23.     MOVEQ #0,D0                     Doesn't matter which version
  24.      MOVE.L 4.w,a6                 EXECBASE
  25.     jsr    -132(a6)                 task switching off (forbid)
  26.      JSR -$228(a6)                  Openlibrary
  27.      MOVE.L D0,GFXBASE             Store library address
  28.  
  29.         
  30. ;Now put the graphic addresses in the CopperList         
  31.  
  32.  
  33.      move.l    #sprite,d1            
  34.      move.w    d1,sp0lo+2
  35.      swap    d1
  36.      move.w    d1,sp0hi+2
  37.  
  38.  
  39.      move.l GFXBASE,d0            Move gfxbase offset to d0
  40.      MOVE.L D0,A6                
  41.      MOVE.W #$80,dmacon(a5)        Turn off copper whilst changing it
  42.      MOVE.L $32(A6),WBCOPPER         Store old (WBench) copper address
  43.      MOVE.L #OURCOPPER,$32(A6)    Point to new copper list (our own)
  44.      MOVE.W #$8080,dmacon(a5)    re-enable copper
  45.  
  46.      MOVE.W #$8010,intena(a5)        
  47.      MOVE.L $6c,old                Save work bench interrupt
  48.      MOVE.L #LEV3,$6c            This sets up a level 3 interrupt
  49.     move.w    intenar(a5),systemints
  50.     move.b    #%01111111,icra        Kill keyboard
  51.         
  52. WAIT:     
  53.     BTST #6,$BFE001                This waits for the left
  54.      BNE.S    WAIT                mouse button to be pressed
  55.     move.l    4.w,a6                EXECBASE
  56.      MOVE.L old,$6c                Restore system interrupts
  57.     MOVE.L GFXBASE,A6
  58.      MOVE.W #$80,dmacon(a5)        Disable DMA
  59.      MOVE.L WBCOPPER,$32(A6)        Restore old copperlist
  60.      MOVE.W #$8080,dmacon(a5)    Enable DMA
  61.      move.w    systemints,d0        Systems interrupt
  62.      or.w    #$c000,d0
  63.      move.w    d0,intena(a5)        Enable OS interrupts
  64.      move.b    #%10011011,icra        Enable keyboard
  65.     clr.w    $dff0a8                Clear music
  66.     clr.w    $dff0b8
  67.     clr.w    $dff0c8
  68.     clr.w    $dff0d8
  69.     move.w    #$f,$dff096
  70.     CLR.L    D0
  71.     rts
  72.  
  73.  
  74. ERROR:    
  75.     move.l 4.w,a6                Get EXECBASE
  76.     jsr    -138(a6)                Permit ( multi-tasking on )
  77.     moveq    #0,d0                Clear d0
  78.      RTS                            Return to AmigaDOS
  79.  
  80.  
  81. ;This is the NEW level 3 interrupt
  82.  
  83. LEV3:
  84.      MOVEM.L d0-d7/a0-a6,-(sp)    Save all registers to the stack
  85.     lea    custom,a5
  86.     AND #$10,intreqr(a5)           Check if interrupt is from Copper 
  87.     BNE out
  88.     move.w    #$8010,$9c                                
  89.     
  90.  
  91. ; ** ALL ROUTINES CALLED (HOPEFULLY) EVERY VBI **
  92.  
  93.     MOVE.W #$FFF,$DFF180
  94.     bsr    try_sin
  95.     bsr    testscroll
  96.  
  97.      move.l    sin_screen,d1        Bitplane memory address
  98.     move.w    d1,bp1lo+2            Used for double buffering
  99.      swap    d1
  100.      move.w    d1,bp1hi+2
  101.  
  102.     bsr        move_stars
  103.     MOVE.W #$000,$DFF180
  104.     
  105.     
  106. out:     
  107.     MOVEM.L (sp)+,d0-d7/a0-a6    Restore the registers
  108.     DC.W $4ef9                    hex value for  JMP instruction
  109. old:     
  110.     DC.L 0                        will jump to normal interrupt
  111.  
  112.  
  113. ; ** Move the sprites **
  114.  
  115. move_stars:
  116.  
  117.     sub.b    #$1,x+1
  118.     sub.b    #$2,x+9
  119.     sub.b    #$1,x+17
  120.     sub.b    #$3,x+25
  121.     sub.b    #$2,x+33
  122.     sub.b    #$4,x+41
  123.     sub.b    #$2,x+49
  124.     sub.b    #$1,x+57
  125.     sub.b    #$3,x+65
  126.     sub.b    #$1,x+73
  127.     sub.b    #$2,x+81
  128.     sub.b    #$4,x+89
  129.     sub.b    #$3,x+97
  130.     sub.b    #$2,x+105
  131.     sub.b    #$1,x+113
  132.     sub.b    #$4,x+121
  133.     sub.b    #$3,x+129
  134.     sub.b    #$3,x+137
  135.     sub.b    #$2,x+145
  136.     sub.b    #$4,x+153
  137.     sub.b    #$1,x+161
  138.     sub.b    #$3,x+169
  139.     sub.b    #$1,x+177
  140.     sub.b    #$2,x+185
  141.     sub.b    #$4,x+193
  142.     sub.b    #$1,x+201
  143.     sub.b    #$3,x+209
  144.     sub.b    #$1,x+217
  145.     sub.b    #$2,x+225
  146.     sub.b    #$2,x+233
  147.     rts
  148.  
  149.  
  150. ; ** Double Buffer The Screen **
  151.  
  152. Buff:
  153.     Eor.l    #10240,Tango                ; Next screen is 10240 bytes along
  154.     Move.l    Tango,D1
  155.     Move.l    #SinePlane,d2
  156.     Add.l    D1,d2
  157.     Move.l    D2,Sin_Screen
  158.     Rts
  159.  
  160.  
  161. ; ** THE SCROLL ROUTINE **
  162.  
  163. testscroll:
  164.     tst.l    stopper
  165.     beq.s    scroll
  166.     sub.l    #1,stopper
  167.     rts
  168. scroll:
  169.     cmp.l    #15*4,val                Blitshifted all <<<
  170.     blo.s    coarse_scroll_it        No then get doing it !!
  171.     bsr        blit_char                Blit letter to screen
  172.     clr.l    val                        Reset index
  173. coarse_scroll_it:
  174.     bsr        coarse                    Scroll all line
  175.     rts                            
  176.     
  177.     
  178. ; ** BLIT LETTER ON THE SCREEN **
  179.  
  180. blit_char
  181.     jsr        text
  182.     lea        custom,a5                Get custom chip address
  183.     move.l    screenx,a0                 Can~t see this picture !!
  184.     move.l    #font,a1                 Put font in blitter source
  185.     add.l    d1,a1
  186. blit_test:
  187.     btst    #14,$dff002                 Blitter busy !!!
  188.     bne    blit_test                     Lets wait till she finishes !
  189.     move.w    #$ffff,bltafwm(a5)        
  190.     move.w    #$ffff,bltalwm(a5)        
  191.     move.l    a0,bltdpth(a5)             Blitter dest D (BOTTOM OF SCREEN)
  192.     move.l    a1,bltapth(a5)             Blitter source A (SCROLLING FONT)
  193.     move.w    #38,bltamod(a5)             Modulo (20-1)*2
  194.     move.w    #38,bltdmod(a5)             Modulo (20-1)*2
  195.     move.w    #$9f0,bltcon0(a5)         Minterms D=A
  196.     clr.w    bltcon1(a5)                 Set Ascending mode
  197.      move.w    #16*64+1,bltsize(a5)     Blit size (SIZE OF FONT)
  198.     rts                                  Return
  199.  
  200.  
  201. ; ** BLITSHIFT THE ENTIRE SCROLL LINE **
  202.  
  203. coarse:
  204.     lea        custom,a5                 
  205.     move.l    screenx,a0                ; Can~t see this picture !!
  206.     move.l    a0,a1
  207.     add.l    #2,a1
  208. blit_wait:
  209.     btst    #14,$dff002            
  210.     bne        blit_wait
  211.     incl    #4,val                    ; (1 for slower)
  212.     move    #15,d7                    ; Amount of pixels to shift(15 for slow)
  213.     ror        #4,d7                    ; Set to correct bits (12-15)
  214.     or        #%100111110000,d7        
  215.     move.l    #-1,bltafwm(a5)
  216.     move.l    a1,bltapth(a5)
  217.     move.l    a0,bltdpth(a5)
  218.     move.w    #0,bltamod(a5)
  219.     move.w    #0,bltdmod(a5)
  220.     move.w    d7,bltcon0(a5)    
  221.     move.w    #80*64+20,bltsize(a5)
  222.     rts    
  223.  
  224.  
  225. ; ** BLITTER CLEAR WHERE THE SINE SCROLL HAS JUST BEEN **
  226.  
  227. CLEAR:
  228.     Move.l    Sin_Screen,a0
  229. wate
  230.     btst    #14,$dff002
  231.     bne.s    wate
  232.     Move.l    a0,Bltdpth(a5)
  233.     Move    #0,Bltdmod(a5)
  234.     Move.l    #$1f00000,Bltcon0(a5)
  235.     Move    #150*64+20,Bltsize(a5)
  236.     Rts
  237.  
  238.  
  239. ; ** DO THE SINEWAVE **
  240. ; BLITTER HAS TO COPY EVERY 2 PIXELS ACROSS, THATS ALOT OF WORK !!!
  241.  
  242. try_sin:
  243.     Bsr        buff
  244.     bsr        clear
  245.     Move.l    Table1,A3
  246.     Move.b    (A3),d1
  247.     Cmp.b    #$ff,d1
  248.     Bne        ItsOkYa
  249.     Move.l    #SinTab,A3
  250. ItsOkYa
  251.     Add.l    hi_amplitude,A3
  252.     Move.l    a3,Table1
  253.     Move.l    A3,Table
  254.     lea        custom,a5                 
  255.     LEA        BLTAFWM(A5),A2            ; FWM           IN A2
  256.     LEA     BLTSIZE(A5),A4            ; BLITSIZE        IN A4
  257.     MOVE.W    #16*64+1,D7                ;                IN D3
  258.     move.l    screenx,D2                 ; Source A
  259.     MOVE.L    D2,BLTAPTH(A5)
  260.     LEA        BLTAPTH(A5),A0
  261.     move.l    #20,d4                    ; Number of chars along screen
  262.     clr.l    d5
  263.     clr.l    d6
  264. ban:
  265.     MOVE.W    #%1100000000000000,d3    ; PUT TO 1 FOR ONE PIXEL 
  266. blit_test0:      
  267.     BSR        BLIT_WAITMAN
  268.     move.w    #$DFC,bltcon0(a5)         
  269.     clr.w    bltcon1(a5)                 
  270.     move.w    #38,bltamod(a5)             
  271.     move.w    #38,bltdmod(a5)             
  272.     move.w    #38,bltbmod(a5)             
  273.      REPT    8
  274.     move.l    sin_screen,a1
  275.     bsr        get_sinvalue
  276.     move.w    d3,(A2)                    ; FWM MASK
  277.     move.l    a1,bltdpth(a5)             
  278.     move.l    a1,bltbpth(a5)             
  279.     move.W    D2,(A0)
  280.     MOVE.W    D7,(A4)                    ; BLITSIZE
  281.     BSR        BLIT_WAITMAN
  282.     LSR        #2,D3
  283.     ENDR
  284.     add.l    #2,a0                    ; Get next letter along
  285.     add.l    #2,d6
  286.     dbf        d4,ban
  287.     rts                                  
  288.  
  289.  
  290.  
  291. BLIT_WAITMAN:
  292.     BTST    #14,$DFF002
  293.     BNE.S    BLIT_WAITMAN
  294.     RTS
  295.     
  296.     
  297. get_sinvalue:
  298.     Clr.l    D5
  299.     Move.l    Table,A3
  300.     Move.b    (A3),d5
  301.     cmp.b    #$ff,d5
  302.     bne        cryptic90
  303.     Move.l    #SinTab,A3
  304.     Move.b    (a3),d5
  305. cryptic90
  306.     Add.l    lo_amplitude,A3
  307.     Move.l    A3,Table
  308.     mulu    #40,d5
  309.     add.l    d5,a1
  310.     Add.l    D6,A1
  311.     rts
  312. Table1:    Dc.l    SinTab    
  313. table:    dc.l    sintab
  314.  
  315.  
  316. ; ** RAY SEE IF YOU CAN GET A BETTER SINUS TABLE FOR FULL SCREEN !!! **
  317. sintab:
  318.     dc.b $3C,$3F,$42,$46,$49,$4C,$50,$53,$56,$59
  319.     dc.b $5C,$5F,$61,$64,$67,$69,$6B,$6D,$6F,$71
  320.     dc.b $72,$73,$75,$76,$76,$77,$77,$77,$77,$77
  321.     dc.b $77,$76,$76,$75,$73,$72,$71,$6F,$6D,$6B
  322.     dc.b $69,$67,$64,$61,$5F,$5C,$59,$56,$53,$50
  323.     dc.b $4C,$49,$46,$42,$3F,$3C,$38,$35,$31,$2E
  324.     dc.b $2B,$27,$24,$21,$1E,$1B,$18,$16,$13,$10
  325.     dc.b $E,$C,$A,$8,$6,$5,$4,$2,$1,$1
  326.     dc.b $0,$0,$0,$0,$0,$0,$1,$1,$2,$4
  327.     dc.b $5,$6,$8,$A,$C,$E,$10,$13,$16,$18
  328.     dc.b $1B,$1E,$21,$24,$27,$2B,$2E,$31,$35
  329.     dc.b $38,255
  330.      EVEN
  331.      
  332.  
  333. ; ** CHARACTER DECODER ROUTINE **
  334.  
  335. text:
  336.     move.l    acurent,a2                Get message
  337.     clr.l    d1                        
  338.     move.b    (a2)+,d1                Update it
  339.     move.b    d1,letter                Store in offset
  340.     cmp.b    #255,d1                    Check for end of message
  341.     beq.w    rst_text                If equal, then reset
  342.     cmp.b    #254,d1
  343.     beq        stop
  344.     sub.l    #32,d1                    Subract 32 (ie space)
  345.     asl        d1                        Times by 2 
  346.     move.l    a2,acurent                Update acurent
  347.     CMP.B    #"4",letter                Is letter "K" or larger
  348.     BPL.s    add_more                If larger then add on
  349.     rts                                Return
  350. add_more:
  351.     CMP.B    #"H",letter                Is letter "U" or larger
  352.     BPL.S    add_more2                If larger then add on
  353.     add.l    #40*15,d1                Get next line down (KLMNOPQRST)
  354.     rts
  355. add_more2:                    
  356.     add.l    #40*30,d1                Get next line down (UVWXYZ0123)
  357.     rts
  358. rst_text:
  359.     move.l    #0,d1
  360.     move.l    #message,d2                Get begining of text
  361.     move.l    d2,acurent                Reset to begining
  362.     rts                                Return
  363. stop:
  364.     move.l    #0,d1
  365.     add.l    #1,acurent
  366.     move.l    #150,stopper
  367.     rts
  368.  
  369. message:
  370.  
  371. ; 254=STOP,255=END.
  372.  
  373.     DC.B    " HI RAY    THIS IS A 2 PIXEL SINE SCROLL (HONESTLY!!)"
  374.     DC.B    "  CHECK OUT THE SINETABLE IN THE SOURCE AND SEE IF YOU CAN GET A BETTER AND BIGGER ONE TO GET FULL SCREEN"
  375.     DC.B    "  ALSO SEE IF KODAK CAN MAKE THIS RUN ANY FASTER COS ITS ABIT SLOOOOW"
  376.     DC.B    "  WRITE SOON....      PS. I'LL SEE YA ALL IN BLACKPOOL ON SATURDAY !!!!!"
  377.     DC.B    "   WRAP           ",255
  378.     EVEN
  379.             
  380.  
  381. ; ** THE COPPERLIST **
  382.  
  383. OURCOPPER:
  384. sp0lo:    dc.w    spr0ptl,$0000
  385. sp0hi:    dc.w    spr0pth,$0000
  386.         dc.w    bpl1mod,0,bpl2mod,0
  387.         dc.w    diwstrt,$2c81+16,diwstop,$2cc1
  388.         dc.w    bplcon0,$1200,bplcon1,$0000
  389.         dc.w    ddfstrt,$38,ddfstop,$d0
  390. *        dc.w    color00,$000,color01,$094
  391.         dc.w    color16,$aaa,color17,$aaa,color18,$aaa
  392.         dc.w    color19,$aaa,color20,$aaa
  393. bp1lo:    dc.w    bpl1ptl,$0000
  394. bp1hi:    dc.w    bpl1pth,$0000
  395.         wait    $2c09,$fffe
  396.         dc.w    color01,$f00
  397.         wait    $2e09,$fffe
  398.         dc.w    color01,$f11
  399.         wait    $3009,$fffe
  400.         dc.w    color01,$f00
  401.         wait    $3209,$fffe
  402.         dc.w    color01,$f11
  403.         wait    $3409,$fffe
  404.         dc.w    color01,$f22
  405.         wait    $3609,$fffe
  406.         dc.w    color01,$f33
  407.         wait    $389,$fffe
  408.         dc.w    color01,$f44
  409.         wait    $3a09,$fffe
  410.         dc.w    color01,$f55
  411.         wait    $3c09,$fffe
  412.         dc.w    color01,$f66
  413.         wait    $3e09,$fffe
  414.         dc.w    color01,$f77
  415.         wait    $4009,$fffe
  416.         dc.w    color01,$f88
  417.         wait    $4209,$fffe
  418.         dc.w    color01,$f99
  419.         wait    $4409,$fffe
  420.         dc.w    color01,$faa
  421.         wait    $4609,$fffe
  422.         dc.w    color01,$fbb
  423.         wait    $4809,$fffe
  424.         dc.w    color01,$fcc
  425.         wait    $4a09,$fffe
  426.         dc.w    color01,$fdd
  427.         wait    $4c09,$fffe
  428.         dc.w    color01,$fee
  429.         wait    $4e09,$fffe
  430.         dc.w    color01,$fff
  431.         wait    $5109,$fffe
  432.         dc.w    color01,$eef
  433.         wait    $5309,$fffe
  434.         dc.w    color01,$ddf
  435.         wait    $5509,$fffe
  436.         dc.w    color01,$ccf
  437.         wait    $5709,$fffe
  438.         dc.w    color01,$bbf
  439.         wait    $5909,$fffe
  440.         dc.w    color01,$aaf
  441.         wait    $5b09,$fffe
  442.         dc.w    color01,$99f
  443.         wait    $5d09,$fffe
  444.         dc.w    color01,$88f
  445.         wait    $5f09,$fffe
  446.         dc.w    color01,$77f
  447.         wait    $6109,$fffe
  448.         dc.w    color01,$66f
  449.         wait    $6309,$fffe
  450.         dc.w    color01,$55f
  451.         wait    $6509,$fffe
  452.         dc.w    color01,$44f
  453.         wait    $6709,$fffe
  454.         dc.w    color01,$33f
  455.         wait    $6909,$fffe
  456.         dc.w    color01,$22f
  457.         wait    $6a09,$fffe
  458.         dc.w    color01,$11f
  459.         wait    $6c09,$fffe
  460.         dc.w    color01,$00f
  461.         wait    $6e09,$fffe
  462.         dc.w    color01,$11f
  463.         wait    $7109,$fffe
  464.         dc.w    color01,$22f
  465.         wait    $7309,$fffe
  466.         dc.w    color01,$33f
  467.         wait    $7509,$fffe
  468.         dc.w    color01,$44f
  469.         wait    $7709,$fffe
  470.         dc.w    color01,$55f
  471.         wait    $7909,$fffe
  472.         dc.w    color01,$66f
  473.         wait    $7a09,$fffe
  474.         dc.w    color01,$77f
  475.         wait    $7c09,$fffe
  476.         dc.w    color01,$88f
  477.         wait    $7e09,$fffe
  478.         dc.w    color01,$99f
  479.         wait    $8009,$fffe
  480.         dc.w    color01,$aaf
  481.         wait    $8209,$fffe
  482.         dc.w    color01,$bbf
  483.         wait    $8409,$fffe
  484.         dc.w    color01,$ccf
  485.         wait    $8609,$fffe
  486.         dc.w    color01,$ddf
  487.         wait    $8809,$fffe
  488.         dc.w    color01,$eef
  489.         wait    $8a09,$fffe
  490.         dc.w    color01,$fff
  491.         wait    $8c09,$fffe
  492.         dc.w    color01,$fee
  493.         wait    $8e09,$fffe
  494.         dc.w    color01,$fdd
  495.         wait    $9109,$fffe
  496.         dc.w    color01,$fcc
  497.         wait    $9309,$fffe
  498.         dc.w    color01,$fbb
  499.         wait    $9509,$fffe
  500.         dc.w    color01,$faa
  501.         wait    $9709,$fffe
  502.         wait    $9909,$fffe
  503.         dc.w    color01,$f99
  504.         wait    $9b09,$fffe
  505.         dc.w    color01,$f88
  506.         wait    $9d09,$fffe
  507.         dc.w    color01,$f77
  508.         wait    $9f09,$fffe
  509.         dc.w    color01,$f66
  510.         end_copper
  511.         
  512.  
  513. ;LOCAL CONSTANTS
  514.  
  515. WBCOPPER:        DC.L    0
  516. GFXLIB:            DC.B     "graphics.library",0
  517. GFXBASE:        DC.L    0
  518. systemints:        dc.l    0
  519. scroll_offset:    dc.l    0
  520. screenx:        dc.l    picture
  521. letter:            dc.b    0
  522. acurent:        dc.l    message
  523. val:            dc.l    0
  524. lo_amplitude:    dc.l    1                        ; PISS AROUND WITH THESE
  525. hi_amplitude:    dc.l    2                        ; PISS AROUND WITH THESE
  526. Tango            Dc.l    0
  527. sin_screen:        Dc.l    SinePlane
  528. stopper:        dc.l    0
  529.  
  530.  
  531. ;BINARY FILES TO BE INCLUDED
  532.     EVEN
  533. picture    
  534.     dcb.b    10240,0
  535. SinePlane
  536.     dcb.b    10240,0
  537.     dcb.b    10240,0
  538. font
  539.     incbin    df1:neatfont.bin
  540. sprite:
  541.     include    df1:sprite.list
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.     
  549.     
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.     
  558.     
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.     
  571.     
  572.